﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace ly.Web.Admin
{
    public partial class EditActivity : System.Web.UI.Page
    {
        ly.BLL.Activity actBll = new BLL.Activity();
        ly.Model.Activity actModel = new Model.Activity();
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                string activityid = Request["id"].Trim();
                string strwhere = "ActivityID = " + activityid;
                DataTable dt = actBll.GetList(strwhere).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    txtworkname.Text = dt.Rows[0]["ActivityName"].ToString().Trim();
                    txtusername.Text = dt.Rows[0]["UserName"].ToString().Trim();
                    startTime.Value = dt.Rows[0]["EndTime"].ToString().Trim();
                    FCKeditor1.Value = dt.Rows[0]["ActivityIntroduction"].ToString().Trim();
                    //ddltype.Text = dt.Rows[0]["Type"].ToString().Trim();

                }
            }
            
        }

        protected void btntianjia_Click1(object sender, EventArgs e)
        {

            actModel = actBll.GetModel(Convert.ToInt32(Request["id"].Trim()));
            actModel.ActivityName = txtworkname.Text.Trim();
            actModel.UserName = txtusername.Text.Trim();
            actModel.EndTime = Convert.ToDateTime(startTime.Value.Trim());
            actModel.ActivityIntroduction = FCKeditor1.Value.Trim();
            bool cou = actBll.Update(actModel);
            if (cou)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('更改成功');</script>");
                Response.Redirect("activityManager.aspx");
                //Maticsoft.Common.MessageBox.ShowAndRedirect(this, "更改成功", "activityManager.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('更改失败');</script>");
            }
        }
        
    }
}